package com.cloudsigns.factorymanager2.produce.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cloudsigns.factorymanager2.BaseActivity;
import com.cloudsigns.factorymanager2.R;
import com.cloudsigns.factorymanager2.produce.adapter.ProduceDailyReportAdapter;
import com.cloudsigns.factorymanager2.project.customview.DropDownPoupWindow;

public class ProduceDailyReportActivity extends BaseActivity{
    private RelativeLayout rl_back,rl_head;
    private TextView tv_title;
    private View ll_op_one, ll_op_two, ll_op_three, ll_op_four;
    private ImageView img_op_one, img_op_two, img_op_three, img_op_four;
    private ImageView img_tri_one,img_tri_two,img_tri_three,img_tri_four;
    private ListView listView;

    /*项目选择*/
    public static final int BTN_SELECT = 0;
    private DropDownPoupWindow popupWindow;

    private ProduceDailyReportAdapter adapter;

    @Override
    protected void onBaseCreate(Bundle savedInstanceState) {
        setContentView(R.layout.layout_produce_daily_report);
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        rl_back = findViewById(R.id.rl_back);
        tv_title = findViewById(R.id.tv_title);
        rl_head=findViewById(R.id.rl_head);
        ll_op_one = findViewById(R.id.ll_op_one);
        ll_op_two = findViewById(R.id.ll_op_two);
        ll_op_two = findViewById(R.id.ll_op_two);
        ll_op_three = findViewById(R.id.ll_op_three);
        ll_op_four = findViewById(R.id.ll_op_four);
        img_op_one = findViewById(R.id.img_op_one);
        img_op_two = findViewById(R.id.img_op_two);
        img_op_three = findViewById(R.id.img_op_three);
        img_op_four = findViewById(R.id.img_op_four);
        img_tri_one=findViewById(R.id.img_tri_one);
        img_tri_two=findViewById(R.id.img_tri_two);
        img_tri_three=findViewById(R.id.img_tri_three);
        img_tri_four=findViewById(R.id.img_tri_four);
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        tv_title.setText(getResources().getString(R.string.process_handover_list));

        img_op_one.setBackgroundResource(R.mipmap.title_icon_menu);
        img_op_two.setBackgroundResource(R.mipmap.icon_hand);
        img_op_three.setBackgroundResource(R.mipmap.icon_produced);
        img_op_four.setBackgroundResource(R.mipmap.icon_patrol);

        ll_op_one.setVisibility(View.GONE);
        ll_op_two.setVisibility(View.GONE);
        ll_op_three.setVisibility(View.GONE);
        ll_op_four.setVisibility(View.VISIBLE);
        rl_back.setVisibility(View.VISIBLE);
        rl_head.setVisibility(View.GONE);

        adapter=new ProduceDailyReportAdapter(this);
    }

    @Override
    public void setListener() {
        ll_op_one.setOnClickListener(this);
        ll_op_two.setOnClickListener(this);
        ll_op_three.setOnClickListener(this);
        ll_op_four.setOnClickListener(this);
        rl_back.setOnClickListener(this);
    }

    /**
     * 功能4
     *
     * @param anchor
     */
    private void showSelectPopupWindwo(View anchor) {
        if (null != popupWindow)
            popupWindow.dismiss();

        popupWindow = new DropDownPoupWindow(this, TAG, BTN_SELECT, R.layout.popwindow_map_for_manager_selectproject, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        img_tri_four.setVisibility(View.VISIBLE);
        popupWindow.setOnClickListener(this);
        popupWindow.setCusOnDismissListener(new PopupWindow.OnDismissListener() {

            @Override
            public void onDismiss() {
                img_tri_four.setVisibility(View.GONE);
            }
        });
        popupWindow.showPopupWindow(anchor, anchor.getLayoutParams().width / 2, 5);
    }

    @Override
    public void widgetClick(View view) {
        Intent mIntent;
        switch (view.getId()) {
            case R.id.rl_back:
                finish();
                break;
            case R.id.ll_op_four:
                showSelectPopupWindwo(view);
                break;
        }
    }
}
